package com.nidu.demo.config;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.config.dto.ConfigAddCmd;
import com.nidu.demo.config.dto.ConfigListQry;
import com.nidu.demo.config.dto.ConfigUpdateCmd;
import com.nidu.demo.config.api.SysConfigService;
import com.nidu.demo.config.dto.ConfigCO;
import com.nidu.demo.config.executor.command.*;
import com.nidu.demo.config.executor.query.*;
import com.nidu.demo.config.ability.ConfigDomainService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 系统配置服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysConfigServiceImpl implements SysConfigService {

    private final ConfigAddCmdExe addCmdExe;
    private final ConfigUpdateCmdExe updateCmdExe;
    private final ConfigDeleteCmdExe deleteCmdExe;
    private final ConfigSingleQryExe singleQryExe;
    private final ConfigListQryExe listQryExe;
    private final ConfigDomainService configDomainService;

    @Override
    public SingleResponse<ConfigCO> add(ConfigAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<ConfigCO> update(ConfigUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<ConfigCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public SingleResponse<ConfigCO> getByKey(String key) {
        // 这里需要实现根据键名查询的逻辑
        return SingleResponse.of(null);
    }

    @Override
    public MultiResponse<ConfigCO> list(ConfigListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public Response updateStatus(Long id, Integer status) {
        configDomainService.updateStatus(id, status);
        return Response.buildSuccess();
    }
} 